package com.dxg.msns.music.mapper;

import com.dxg.msns.music.pojo.MusicGrade;
import com.dxg.msns.music.pojo.MusicGradeDTO;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.BaseMapper;

import java.util.List;
@Mapper
public interface MusicGradeMapper extends BaseMapper<MusicGrade> {
    @Select("SELECT music_grade FROM music_grade WHERE music_id = #{musicId}")
    @Results({
            @Result(property = "musicGrade", column = "music_grade")
    })
    List<MusicGrade> selectByMusicIds(@Param("musicId") String musicId);
    @Select("<script>" +
            "SELECT music_id, music_grade, status FROM music_grade " +
            "WHERE music_id IN " +
            "<foreach item='id' collection='musicIds' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "</script>")
    @Results({
            @Result(property = "musicId", column = "music_id"),
            @Result(property = "musicGrade", column = "music_grade"),
            @Result(property = "status", column = "status")
    })
    List<MusicGradeDTO> selectByMusicIdes(@Param("musicIds") List<String> musicIds);
    @Select("SELECT * FROM music_grade WHERE user_id = #{userId} AND music_id = #{musicId}")
    List<MusicGrade> selectByUserAndMusicId(@Param("userId") String userId, @Param("musicId") String musicId);


}
